/**
 * @author LKQ
 * @date 2021/12/11 16:24
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        int[][] groups = {{1, -1, -1}, {3, -2, 0}};
        int[] nums = {1, -1, 0, 1,-1, -1,3, -2 ,0};
        Solution solution = new Solution();
        solution.canChoose(groups, nums);
    }
    public boolean canChoose(int[][] groups, int[] nums) {
        int n = nums.length;
        int start = 0, start1 = 0, k = 0;
        int[] group1;
        boolean isFinish = false;
        while(start < n) {
            if (k >= groups.length) {
                break;
            }
            group1 = groups[k];
            if(start1 < group1.length) {
                if(nums[start] == group1[start1]) {
                    start1++;
                }else {
                    start = start - start1;
                    start1 = 0;
                }
                start++;
                if (start != n) {
                    continue;
                }
            }
            if (start1 == group1.length) {
                k++;
            }
            start1 = 0;
            if(k == groups.length) {
                isFinish = true;
            }
        }
        return isFinish;
    }
}
